﻿package core.drawing
{
    import core.enum.*;
    import flash.events.*;

    final public class PickerTool extends Tool
    {

        public function PickerTool(param1:Tuyitu)
        {
            super(param1, ToolType.Picker, false);
            return;
        }// end function

        override public function MouseDown(event:MouseEvent) : void
        {
            this.UpdateReferences();
            ed.cursor.freeze = true;
            ed.addEventListener(MouseEvent.MOUSE_MOVE, this.MouseDrag, false, 1, true);
            ed.addEventListener(MouseEvent.MOUSE_UP, this.MouseUp, false, 1, true);
            this.SetColor(event.shiftKey);
            return;
        }// end function

        override public function MouseDrag(event:MouseEvent) : void
        {
            this.SetColor(event.shiftKey);
            return;
        }// end function

        override public function MouseUp(event:MouseEvent) : void
        {
            ed.cursor.freeze = false;
            ed.removeEventListener(MouseEvent.MOUSE_MOVE, this.MouseDrag, false);
            ed.removeEventListener(MouseEvent.MOUSE_UP, this.MouseUp, false);
            return;
        }// end function

        private function SetColor(param1:Boolean)
        {
            ed.toolbar.SetColor(param1 ? (2) : (1), canvas.screenshot.getPixel32((Math.ceil(document.mouseX) - 1), int(document.mouseY)));
            return;
        }// end function

    }
}
